home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-06 | 2.2 KB | 107 lines | [TEXT/CWIE] |
- {•This sourcecode is an example for creating a FKey coderesource with•}
- {•Metrowerks Pascal. It is copyrighted by Peter Hoerster and released•}
- {•for free use in any Shareware or Freeware product as a way to thank all•}
- {•programmers who share code snippets. You may put this sources on any•}
- {•CD ROM or any Archive Server but you may not sell it. •}
-
- {• For comments please write to <hoerster@muenster.de>•}
-
-
-
- unit WordCaps;
-
- interface
-
- uses
- Types, OSUtils, GestaltEqu, Script, notification, Resources, Events,
- QuickDraw, ToolUtils, Memory, LowMem, Scrap,pascalA4;
-
-
-
- {$MAIN}
-
- procedure main;
-
- implementation
-
- procedure dopaste;
- const
- pastecode=2422;
- var
- qel: EvQelPtr;
- begin
-
- if ppostevent(3, pastecode, qel) = noerr then
- qel^.evtqmodifiers := cmdkey;
- end;
-
-
- procedure main;
-
- var
- oldA4: LongInt;
- myerr: oserr;
- myclipsize, templongint: longint;
- myclipHandle: handle;
-
-
- procedure doLowercase;
- const
- step = 1000;
- var
-
- count, pos,rest,i,amount: longint;
- begin
- pos:=0;
- count:=myclipsize div step;
- rest:=myclipsize mod step;
-
- for i := 1 to count do
- begin
- amount := step;
- lowertext(Ptr(ord4(myclipHandle^)+pos), amount);
- pos := i * step;
- end;
- lowertext(Ptr(ord4(mycliphandle^)+pos), rest);
- end;
- procedure doCapitals;
- var
- offset: integer;
- offsets: OffsetTable;
-
- begin
- doLowercase;
- offset := 0;
- repeat
- FindWord(myclipHandle^, myclipsize, offset, true, nil, offsets);
- offset := offsets[0].offfirst;
- uppertext(ptr(ord4(myclipHandle^) + offset), 1);
- offset := offsets[0].offsecond;
- until offset >= myclipsize;
- end;
-
- begin
- oldA4 := SetCurrentA4;
- myclipsize := GetScrap(nil, 'TEXT', templongint);
- mycliphandle := Tempnewhandle(myclipsize,myerr);
- if myerr=noerr then
- begin
- myclipsize := GetScraP(myclipHandle, 'TEXT', templongint);
- if myclipsize > 0 then
- begin
- Temphlock(mycliphandle,myerr);
- if myerr=noerr then
- begin
-
- doCapitals;
- myerr := ZeroScrap;
- myerr := putscrap(myclipsize, 'TEXT', myclipHandle^);
- dopaste;
- end;
- Temphunlock(myCliphandle,myerr);
- end;
- end;
- TempDisposeHandle(myCliphandle,myerr);
- oldA4 := SetA4(oldA4);
- end;
- end.